﻿angular.module("freelancerModule.Directives", []).
directive("highlight", function ($filter) {
    var dayFilter = $filter("dayName");
    return function (scope, element, attrs) {
        if (dayFilter(scope.day) === attrs["highlight"]) {
            element.css("color", "red");
        }
    };
}).directive('footer', function () {
    return {
        restrict: 'A', //This menas that it will be used as an attribute and NOT as an element. 
        replace: true,
        templateUrl: "app/components/footer/footer.html",
        controller: ['$scope', '$filter', function ($scope, $filter) {
            // Your behaviour goes here :)
        }]
    }
}).directive('header', function () {
    return {
        restrict: 'A', //This menas that it will be used as an attribute and NOT as an element
        replace: true,
        scope: { user: '=' },
        templateUrl: "app/components/header/header.html",
        controller: ['$scope', '$filter', function ($scope, $filter) {
            // Your behaviour goes here :)
        }]
    }
}).directive("renderJsElements", function () {
    return {
        restrict: "A",
        link: function (scope, element, attrs) {
            /* In this dummy example, we're setting a text, but if working with ui frameworks we may init here several instances of a dropdown, ($(".thisIsADropdown).dropdown()) 
            so we will run this directive only once applying the "M" Comment restriction by placing that comment at the end of the template file. Your feedback will be highly appreciated */
            //$(".textdouble").html("Im set from inside a directive");
            //console.log(element);
            element.ready(function () {
                //console.log(element);
                element.carousel({
                    interval: 4000 //changes the speed
                });
            });
        }
    }
}).directive('toolbarTip', function () {
    return {
        // Restrict it to be an attribute in this case
        restrict: 'A',
        // responsible for registering DOM listeners as well as updating the DOM
        link: function (scope, element, attrs) {
            $(element).toolbar(scope.$eval(attrs.toolbarTip));
        }
    };
});